package com.health.trans.kit;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;
import java.util.Properties;

/**
 * @author nqlz
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class KafkaReaderConfig<T> extends ReaderConfig<T> {

    private String bootstrapServers;
    private List<Integer> partitions;
    private String topic;
    private String groupId;
    private String autoOffsetReset = "earliest";
    private String maxPollRecords = "50";
    private String enableAutoCommit = "false";
    private String autoCommitInterval = "3000";
    private String keyDeserializer = "org.apache.kafka.common.serialization.StringDeserializer";
    private String valueDeserializer = "org.apache.kafka.common.serialization.StringDeserializer";

    private Properties properties;


    public Properties getProperty(){
        Properties properties = new Properties();
        properties.setProperty("bootstrap.servers", bootstrapServers);
        properties.setProperty("group.id", groupId);
        properties.setProperty("auto.offset.reset", autoOffsetReset);
        properties.setProperty("max.poll.records",maxPollRecords);
        properties.setProperty("enable.auto.commit", enableAutoCommit);
        properties.setProperty("auto.commit.interval", autoCommitInterval);
        properties.setProperty("key.deserializer", keyDeserializer);
        properties.setProperty("value.deserializer", valueDeserializer);
        return properties;
    }
}
